
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.io.exciting.inputs &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
    <script src="../../../../_static/jquery.js"></script>
    <script src="../../../../_static/underscore.js"></script>
    <script src="../../../../_static/doctools.js"></script>
    <script src="../../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.exciting.inputs</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.io.exciting.inputs</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Classes for reading/manipulating/writing exciting input files.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<span class="kn">from</span> <span class="nn">monty.io</span> <span class="kn">import</span> <span class="n">zopen</span>

<span class="kn">import</span> <span class="nn">xml.etree.cElementTree</span> <span class="k">as</span> <span class="nn">ET</span>

<span class="kn">import</span> <span class="nn">scipy.constants</span> <span class="k">as</span> <span class="nn">const</span>

<span class="kn">from</span> <span class="nn">pymatgen.core.lattice</span> <span class="kn">import</span> <span class="n">Lattice</span>
<span class="kn">from</span> <span class="nn">pymatgen.core.structure</span> <span class="kn">import</span> <span class="n">Structure</span>
<span class="kn">from</span> <span class="nn">pymatgen.core.periodic_table</span> <span class="kn">import</span> <span class="n">Element</span>
<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">MSONable</span>

<span class="kn">from</span> <span class="nn">pymatgen.symmetry.analyzer</span> <span class="kn">import</span> <span class="n">SpacegroupAnalyzer</span>
<span class="kn">from</span> <span class="nn">pymatgen.symmetry.bandstructure</span> <span class="kn">import</span> <span class="n">HighSymmKpath</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="s2">&quot;Christian Vorwerk&quot;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s2">&quot;Copyright 2016&quot;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;1.0&quot;</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s2">&quot;Christian Vorwerk&quot;</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">&quot;vorwerk@physik.hu-berlin.de&quot;</span>
<span class="n">__status__</span> <span class="o">=</span> <span class="s2">&quot;Development&quot;</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s2">&quot;Nov 28, 2016&quot;</span>


<div class="viewcode-block" id="ExcitingInput"><a class="viewcode-back" href="../../../../pymatgen.io.exciting.inputs.html#pymatgen.io.exciting.inputs.ExcitingInput">[docs]</a><span class="k">class</span> <span class="nc">ExcitingInput</span><span class="p">(</span><span class="n">MSONable</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Object for representing the data stored in the structure part of the</span>
<span class="sd">    exciting input.</span>

<span class="sd">    .. attribute:: structure</span>

<span class="sd">        Associated Structure.</span>

<span class="sd">    .. attribute:: title</span>

<span class="sd">        Optional title string.</span>

<span class="sd">    .. attribute:: lockxyz</span>

<span class="sd">        Lockxyz attribute for each site if available. A Nx3 array of</span>
<span class="sd">        booleans.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">lockxyz</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            structure (Structure):  Structure object.</span>
<span class="sd">            title (str): Optional title for exciting input. Defaults to unit</span>
<span class="sd">                cell formula of structure. Defaults to None.</span>
<span class="sd">            lockxyz (Nx3 array): bool values for selective dynamics,</span>
<span class="sd">                where N is number of sites. Defaults to None.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">structure</span><span class="o">.</span><span class="n">is_ordered</span><span class="p">:</span>
            <span class="n">site_properties</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">if</span> <span class="n">lockxyz</span><span class="p">:</span>
                <span class="n">site_properties</span><span class="p">[</span><span class="s2">&quot;selective_dynamics&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">lockxyz</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">structure</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">site_properties</span><span class="o">=</span><span class="n">site_properties</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">formula</span> <span class="k">if</span> <span class="n">title</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">title</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Structure with partial occupancies cannot be &quot;</span>
                             <span class="s2">&quot;converted into exciting input!&quot;</span><span class="p">)</span>

    <span class="c1"># define conversion factor between Bohr radius and Angstrom</span>
    <span class="n">bohr2ang</span> <span class="o">=</span> <span class="n">const</span><span class="o">.</span><span class="n">value</span><span class="p">(</span><span class="s1">&#39;Bohr radius&#39;</span><span class="p">)</span> <span class="o">/</span> <span class="n">const</span><span class="o">.</span><span class="n">value</span><span class="p">(</span><span class="s1">&#39;Angstrom star&#39;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">lockxyz</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Selective dynamics site properties.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">site_properties</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;selective_dynamics&quot;</span><span class="p">)</span>

    <span class="nd">@lockxyz</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">lockxyz</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lockxyz</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">add_site_property</span><span class="p">(</span><span class="s2">&quot;selective_dynamics&quot;</span><span class="p">,</span>
                                         <span class="n">lockxyz</span><span class="p">)</span>

<div class="viewcode-block" id="ExcitingInput.from_string"><a class="viewcode-back" href="../../../../pymatgen.io.exciting.inputs.html#pymatgen.io.exciting.inputs.ExcitingInput.from_string">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_string</span><span class="p">(</span><span class="n">data</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Reads the exciting input from a string</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">root</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">fromstring</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
        <span class="n">speciesnode</span> <span class="o">=</span> <span class="n">root</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;structure&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">iter</span><span class="p">(</span><span class="s1">&#39;species&#39;</span><span class="p">)</span>
        <span class="n">elements</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">positions</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">vectors</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">lockxyz</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="c1"># get title</span>
        <span class="n">title_in</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">root</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;title&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">text</span><span class="p">)</span>
        <span class="c1"># Read elements and coordinates</span>
        <span class="k">for</span> <span class="n">nodes</span> <span class="ow">in</span> <span class="n">speciesnode</span><span class="p">:</span>
            <span class="n">symbol</span> <span class="o">=</span> <span class="n">nodes</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;speciesfile&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;.&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">symbol</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">))</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                <span class="n">symbol</span> <span class="o">=</span> <span class="n">symbol</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">Element</span><span class="o">.</span><span class="n">is_valid_symbol</span><span class="p">(</span><span class="n">symbol</span><span class="p">):</span>
                <span class="c1"># Try to recognize the element symbol</span>
                <span class="n">element</span> <span class="o">=</span> <span class="n">symbol</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Unknown element!&quot;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">atom</span> <span class="ow">in</span> <span class="n">nodes</span><span class="o">.</span><span class="n">iter</span><span class="p">(</span><span class="s1">&#39;atom&#39;</span><span class="p">):</span>
                <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">atom</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;coord&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                <span class="n">positions</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="nb">float</span><span class="p">(</span><span class="n">y</span><span class="p">),</span> <span class="nb">float</span><span class="p">(</span><span class="n">z</span><span class="p">)])</span>
                <span class="n">elements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
                <span class="c1"># Obtain lockxyz for each atom</span>
                <span class="k">if</span> <span class="n">atom</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;lockxyz&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                    <span class="n">lxyz</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">atom</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;lockxyz&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">():</span>
                        <span class="k">if</span> <span class="n">l</span> <span class="o">==</span> <span class="s1">&#39;True&#39;</span> <span class="ow">or</span> <span class="n">l</span> <span class="o">==</span> <span class="s1">&#39;true&#39;</span><span class="p">:</span>
                            <span class="n">lxyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">lxyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="kc">False</span><span class="p">)</span>
                    <span class="n">lockxyz</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">lxyz</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">lockxyz</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="kc">False</span><span class="p">,</span> <span class="kc">False</span><span class="p">,</span> <span class="kc">False</span><span class="p">])</span>
        <span class="c1"># check the atomic positions type</span>
        <span class="k">if</span> <span class="s1">&#39;cartesian&#39;</span> <span class="ow">in</span> <span class="n">root</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;structure&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">attrib</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">root</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;structure&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">attrib</span><span class="p">[</span><span class="s1">&#39;cartesian&#39;</span><span class="p">]:</span>
                <span class="n">cartesian</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">positions</span><span class="p">)):</span>
                    <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">positions</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">positions</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">*</span> <span class="n">ExcitingInput</span><span class="o">.</span><span class="n">bohr2ang</span>
                <span class="nb">print</span><span class="p">(</span><span class="n">positions</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">cartesian</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="c1"># get the scale attribute</span>
        <span class="n">scale_in</span> <span class="o">=</span> <span class="n">root</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;structure&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;crystal&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;scale&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">scale_in</span><span class="p">:</span>
            <span class="n">scale</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">scale_in</span><span class="p">)</span> <span class="o">*</span> <span class="n">ExcitingInput</span><span class="o">.</span><span class="n">bohr2ang</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">scale</span> <span class="o">=</span> <span class="n">ExcitingInput</span><span class="o">.</span><span class="n">bohr2ang</span>
        <span class="c1"># get the stretch attribute</span>
        <span class="n">stretch_in</span> <span class="o">=</span> <span class="n">root</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;structure&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;crystal&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;stretch&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">stretch_in</span><span class="p">:</span>
            <span class="n">stretch</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">stretch_in</span><span class="p">])</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">stretch</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">])</span>
        <span class="c1"># get basis vectors and scale them accordingly</span>
        <span class="n">basisnode</span> <span class="o">=</span> <span class="n">root</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;structure&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;crystal&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">iter</span><span class="p">(</span><span class="s1">&#39;basevect&#39;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">vect</span> <span class="ow">in</span> <span class="n">basisnode</span><span class="p">:</span>
            <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">vect</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="n">vectors</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">*</span> <span class="n">stretch</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">scale</span><span class="p">,</span>
                            <span class="nb">float</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">*</span> <span class="n">stretch</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">scale</span><span class="p">,</span>
                            <span class="nb">float</span><span class="p">(</span><span class="n">z</span><span class="p">)</span> <span class="o">*</span> <span class="n">stretch</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">*</span> <span class="n">scale</span><span class="p">])</span>
        <span class="c1"># create lattice and structure object</span>
        <span class="n">lattice_in</span> <span class="o">=</span> <span class="n">Lattice</span><span class="p">(</span><span class="n">vectors</span><span class="p">)</span>
        <span class="n">structure_in</span> <span class="o">=</span> <span class="n">Structure</span><span class="p">(</span><span class="n">lattice_in</span><span class="p">,</span> <span class="n">elements</span><span class="p">,</span> <span class="n">positions</span><span class="p">,</span> <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="n">cartesian</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">ExcitingInput</span><span class="p">(</span><span class="n">structure_in</span><span class="p">,</span> <span class="n">title_in</span><span class="p">,</span> <span class="n">lockxyz</span><span class="p">)</span></div>

<div class="viewcode-block" id="ExcitingInput.from_file"><a class="viewcode-back" href="../../../../pymatgen.io.exciting.inputs.html#pymatgen.io.exciting.inputs.ExcitingInput.from_file">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_file</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param filename: Filename</span>
<span class="sd">        :return: ExcitingInput</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">ExcitingInput</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">data</span><span class="p">)</span></div>

<div class="viewcode-block" id="ExcitingInput.write_etree"><a class="viewcode-back" href="../../../../pymatgen.io.exciting.inputs.html#pymatgen.io.exciting.inputs.ExcitingInput.write_etree">[docs]</a>    <span class="k">def</span> <span class="nf">write_etree</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">celltype</span><span class="p">,</span> <span class="n">cartesian</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">bandstr</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="mf">0.4</span><span class="p">,</span> <span class="n">angle_tolerance</span><span class="o">=</span><span class="mi">5</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param celltype:</span>
<span class="sd">        :param cartesian:</span>
<span class="sd">        :param bandstr:</span>
<span class="sd">        :param symprec:</span>
<span class="sd">        :param angle_tolerance:</span>
<span class="sd">        :return:</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">root</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">Element</span><span class="p">(</span><span class="s1">&#39;input&#39;</span><span class="p">)</span>
        <span class="n">root</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;{http://www.w3.org/2001/XMLSchema-instance}noNamespaceSchemaLocation&#39;</span><span class="p">,</span>
                 <span class="s1">&#39;http://xml.exciting-code.org/excitinginput.xsd&#39;</span><span class="p">)</span>
        <span class="n">title</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="s1">&#39;title&#39;</span><span class="p">)</span>
        <span class="n">title</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span>
        <span class="k">if</span> <span class="n">cartesian</span><span class="p">:</span>
            <span class="n">structure</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="s1">&#39;structure&#39;</span><span class="p">,</span> <span class="n">cartesian</span><span class="o">=</span><span class="s2">&quot;true&quot;</span><span class="p">,</span> <span class="n">speciespath</span><span class="o">=</span><span class="s2">&quot;./&quot;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">structure</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="s1">&#39;structure&#39;</span><span class="p">,</span> <span class="n">speciespath</span><span class="o">=</span><span class="s2">&quot;./&quot;</span><span class="p">)</span>

        <span class="n">crystal</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="s1">&#39;crystal&#39;</span><span class="p">)</span>
        <span class="c1"># set scale such that lattice vector can be given in Angstrom</span>
        <span class="n">ang2bohr</span> <span class="o">=</span> <span class="n">const</span><span class="o">.</span><span class="n">value</span><span class="p">(</span><span class="s1">&#39;Angstrom star&#39;</span><span class="p">)</span> <span class="o">/</span> <span class="n">const</span><span class="o">.</span><span class="n">value</span><span class="p">(</span><span class="s1">&#39;Bohr radius&#39;</span><span class="p">)</span>
        <span class="n">crystal</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s1">&#39;scale&#39;</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">ang2bohr</span><span class="p">))</span>
        <span class="c1"># determine which structure to use</span>
        <span class="n">finder</span> <span class="o">=</span> <span class="n">SpacegroupAnalyzer</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="n">symprec</span><span class="p">,</span> <span class="n">angle_tolerance</span><span class="o">=</span><span class="n">angle_tolerance</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">celltype</span> <span class="o">==</span> <span class="s1">&#39;primitive&#39;</span><span class="p">:</span>
            <span class="n">new_struct</span> <span class="o">=</span> <span class="n">finder</span><span class="o">.</span><span class="n">get_primitive_standard_structure</span><span class="p">(</span><span class="n">international_monoclinic</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">celltype</span> <span class="o">==</span> <span class="s1">&#39;conventional&#39;</span><span class="p">:</span>
            <span class="n">new_struct</span> <span class="o">=</span> <span class="n">finder</span><span class="o">.</span><span class="n">get_conventional_standard_structure</span><span class="p">(</span><span class="n">international_monoclinic</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">celltype</span> <span class="o">==</span> <span class="s1">&#39;unchanged&#39;</span><span class="p">:</span>
            <span class="n">new_struct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Type of unit cell not recognized!&#39;</span><span class="p">)</span>

        <span class="c1"># write lattice</span>
        <span class="n">basis</span> <span class="o">=</span> <span class="n">new_struct</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">matrix</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
            <span class="n">basevect</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">crystal</span><span class="p">,</span> <span class="s1">&#39;basevect&#39;</span><span class="p">)</span>
            <span class="n">basevect</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">%16.8f</span><span class="s2"> </span><span class="si">%16.8f</span><span class="s2"> </span><span class="si">%16.8f</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">basis</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="n">basis</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">],</span>
                                                      <span class="n">basis</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">2</span><span class="p">])</span>
        <span class="c1"># write atomic positions for each species</span>
        <span class="n">index</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">new_struct</span><span class="o">.</span><span class="n">types_of_specie</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">el</span><span class="p">:</span> <span class="n">el</span><span class="o">.</span><span class="n">X</span><span class="p">):</span>
            <span class="n">species</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="s1">&#39;species&#39;</span><span class="p">,</span> <span class="n">speciesfile</span><span class="o">=</span><span class="n">i</span><span class="o">.</span><span class="n">symbol</span> <span class="o">+</span> <span class="s1">&#39;.xml&#39;</span><span class="p">)</span>
            <span class="n">sites</span> <span class="o">=</span> <span class="n">new_struct</span><span class="o">.</span><span class="n">indices_from_symbol</span><span class="p">(</span><span class="n">i</span><span class="o">.</span><span class="n">symbol</span><span class="p">)</span>

            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">sites</span><span class="p">:</span>
                <span class="n">coord</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">%16.8f</span><span class="s2"> </span><span class="si">%16.8f</span><span class="s2"> </span><span class="si">%16.8f</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">new_struct</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                                                  <span class="n">new_struct</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
                                                  <span class="n">new_struct</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
                <span class="c1"># obtain cartesian coords from fractional ones if needed</span>
                <span class="k">if</span> <span class="n">cartesian</span><span class="p">:</span>
                    <span class="n">coord2</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">inter</span> <span class="o">=</span> <span class="p">(</span><span class="n">new_struct</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">*</span> <span class="n">basis</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">k</span><span class="p">]</span> <span class="o">+</span>
                                 <span class="n">new_struct</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">*</span> <span class="n">basis</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="n">k</span><span class="p">]</span> <span class="o">+</span>
                                 <span class="n">new_struct</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">*</span> <span class="n">basis</span><span class="p">[</span><span class="mi">2</span><span class="p">][</span><span class="n">k</span><span class="p">])</span> <span class="o">*</span> <span class="n">ang2bohr</span>
                        <span class="n">coord2</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">inter</span><span class="p">)</span>
                    <span class="n">coord</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">%16.8f</span><span class="s2"> </span><span class="si">%16.8f</span><span class="s2"> </span><span class="si">%16.8f</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">coord2</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                                                      <span class="n">coord2</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
                                                      <span class="n">coord2</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>

                <span class="c1"># write atomic positions</span>
                <span class="n">index</span> <span class="o">=</span> <span class="n">index</span> <span class="o">+</span> <span class="mi">1</span>
                <span class="n">_</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">species</span><span class="p">,</span> <span class="s1">&#39;atom&#39;</span><span class="p">,</span> <span class="n">coord</span><span class="o">=</span><span class="n">coord</span><span class="p">)</span>
        <span class="c1"># write bandstructure if needed</span>
        <span class="k">if</span> <span class="n">bandstr</span> <span class="ow">and</span> <span class="n">celltype</span> <span class="o">==</span> <span class="s1">&#39;primitive&#39;</span><span class="p">:</span>
            <span class="n">kpath</span> <span class="o">=</span> <span class="n">HighSymmKpath</span><span class="p">(</span><span class="n">new_struct</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="n">symprec</span><span class="p">,</span> <span class="n">angle_tolerance</span><span class="o">=</span><span class="n">angle_tolerance</span><span class="p">)</span>
            <span class="n">prop</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="s1">&#39;properties&#39;</span><span class="p">)</span>
            <span class="n">bandstrct</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">prop</span><span class="p">,</span> <span class="s1">&#39;bandstructure&#39;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">kpath</span><span class="o">.</span><span class="n">kpath</span><span class="p">[</span><span class="s1">&#39;path&#39;</span><span class="p">])):</span>
                <span class="n">plot</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">bandstrct</span><span class="p">,</span> <span class="s1">&#39;plot1d&#39;</span><span class="p">)</span>
                <span class="n">path</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">plot</span><span class="p">,</span> <span class="s1">&#39;path&#39;</span><span class="p">,</span> <span class="n">steps</span><span class="o">=</span><span class="s1">&#39;100&#39;</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">kpath</span><span class="o">.</span><span class="n">kpath</span><span class="p">[</span><span class="s1">&#39;path&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">])):</span>
                    <span class="n">symbol</span> <span class="o">=</span> <span class="n">kpath</span><span class="o">.</span><span class="n">kpath</span><span class="p">[</span><span class="s1">&#39;path&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
                    <span class="n">coords</span> <span class="o">=</span> <span class="n">kpath</span><span class="o">.</span><span class="n">kpath</span><span class="p">[</span><span class="s1">&#39;kpoints&#39;</span><span class="p">][</span><span class="n">symbol</span><span class="p">]</span>
                    <span class="n">coord</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">%16.8f</span><span class="s2"> </span><span class="si">%16.8f</span><span class="s2"> </span><span class="si">%16.8f</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">coords</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                                                      <span class="n">coords</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
                                                      <span class="n">coords</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
                    <span class="k">if</span> <span class="n">symbol</span> <span class="o">==</span> <span class="s1">&#39;</span><span class="se">\\</span><span class="s1">Gamma&#39;</span><span class="p">:</span>
                        <span class="n">symbol</span> <span class="o">=</span> <span class="s1">&#39;GAMMA&#39;</span>
                    <span class="n">_</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">SubElement</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s1">&#39;point&#39;</span><span class="p">,</span> <span class="n">coord</span><span class="o">=</span><span class="n">coord</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">symbol</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">bandstr</span> <span class="ow">and</span> <span class="n">celltype</span> <span class="o">!=</span> <span class="s1">&#39;primitive&#39;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Bandstructure is only implemented for the </span><span class="se">\</span>
<span class="s2">                              standard primitive unit cell!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">root</span></div>

<div class="viewcode-block" id="ExcitingInput.write_string"><a class="viewcode-back" href="../../../../pymatgen.io.exciting.inputs.html#pymatgen.io.exciting.inputs.ExcitingInput.write_string">[docs]</a>    <span class="k">def</span> <span class="nf">write_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">celltype</span><span class="p">,</span> <span class="n">cartesian</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">bandstr</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="mf">0.4</span><span class="p">,</span> <span class="n">angle_tolerance</span><span class="o">=</span><span class="mi">5</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Writes to a string.</span>

<span class="sd">        :param celltype:</span>
<span class="sd">        :param cartesian:</span>
<span class="sd">        :param bandstr:</span>
<span class="sd">        :param symprec:</span>
<span class="sd">        :param angle_tolerance:</span>
<span class="sd">        :return:</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">root</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">write_etree</span><span class="p">(</span><span class="n">celltype</span><span class="p">,</span> <span class="n">cartesian</span><span class="p">,</span> <span class="n">bandstr</span><span class="p">,</span> <span class="n">symprec</span><span class="p">,</span> <span class="n">angle_tolerance</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">root</span><span class="p">)</span>
            <span class="c1"># output should be a string not a bytes object</span>
            <span class="n">string</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">tostring</span><span class="p">(</span><span class="n">root</span><span class="p">)</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;UTF-8&#39;</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Incorrect celltype!&#39;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">string</span></div>

<div class="viewcode-block" id="ExcitingInput.write_file"><a class="viewcode-back" href="../../../../pymatgen.io.exciting.inputs.html#pymatgen.io.exciting.inputs.ExcitingInput.write_file">[docs]</a>    <span class="k">def</span> <span class="nf">write_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">celltype</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">cartesian</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">bandstr</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">symprec</span><span class="o">=</span><span class="mf">0.4</span><span class="p">,</span> <span class="n">angle_tolerance</span><span class="o">=</span><span class="mi">5</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Write to a file.</span>

<span class="sd">        :param celltype:</span>
<span class="sd">        :param filename:</span>
<span class="sd">        :param cartesian:</span>
<span class="sd">        :param bandstr:</span>
<span class="sd">        :param symprec:</span>
<span class="sd">        :param angle_tolerance:</span>
<span class="sd">        :return:</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">root</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">write_etree</span><span class="p">(</span><span class="n">celltype</span><span class="p">,</span> <span class="n">cartesian</span><span class="p">,</span> <span class="n">bandstr</span><span class="p">,</span> <span class="n">symprec</span><span class="p">,</span> <span class="n">angle_tolerance</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">root</span><span class="p">)</span>
            <span class="n">tree</span> <span class="o">=</span> <span class="n">ET</span><span class="o">.</span><span class="n">ElementTree</span><span class="p">(</span><span class="n">root</span><span class="p">)</span>
            <span class="n">tree</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Incorrect celltype!&#39;</span><span class="p">)</span>
        <span class="k">return</span></div>

    <span class="c1"># Missing PrerryPrint option in the current version of xml.etree.cElementTree</span>
<div class="viewcode-block" id="ExcitingInput.indent"><a class="viewcode-back" href="../../../../pymatgen.io.exciting.inputs.html#pymatgen.io.exciting.inputs.ExcitingInput.indent">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">indent</span><span class="p">(</span><span class="n">elem</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Helper method to indent elements.</span>

<span class="sd">        :param elem:</span>
<span class="sd">        :param level:</span>
<span class="sd">        :return:</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">i</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">+</span> <span class="n">level</span> <span class="o">*</span> <span class="s2">&quot;  &quot;</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">elem</span><span class="p">):</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">elem</span><span class="o">.</span><span class="n">text</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">elem</span><span class="o">.</span><span class="n">text</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span>
                <span class="n">elem</span><span class="o">.</span><span class="n">text</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="s2">&quot;  &quot;</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">elem</span><span class="o">.</span><span class="n">tail</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">elem</span><span class="o">.</span><span class="n">tail</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span>
                <span class="n">elem</span><span class="o">.</span><span class="n">tail</span> <span class="o">=</span> <span class="n">i</span>
            <span class="k">for</span> <span class="n">elem</span> <span class="ow">in</span> <span class="n">elem</span><span class="p">:</span>
                <span class="n">ExcitingInput</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">elem</span><span class="p">,</span> <span class="n">level</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">elem</span><span class="o">.</span><span class="n">tail</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">elem</span><span class="o">.</span><span class="n">tail</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span>
                <span class="n">elem</span><span class="o">.</span><span class="n">tail</span> <span class="o">=</span> <span class="n">i</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">level</span> <span class="ow">and</span> <span class="p">(</span><span class="ow">not</span> <span class="n">elem</span><span class="o">.</span><span class="n">tail</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">elem</span><span class="o">.</span><span class="n">tail</span><span class="o">.</span><span class="n">strip</span><span class="p">()):</span>
                <span class="n">elem</span><span class="o">.</span><span class="n">tail</span> <span class="o">=</span> <span class="n">i</span></div></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.exciting.inputs</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>